<?xml version="1.0" encoding="UTF-8" ?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml"
      xmlns:ui="http://xmlns.jcp.org/jsf/facelets"
      xmlns:h="http://xmlns.jcp.org/jsf/html"
      xmlns:f="http://xmlns.jcp.org/jsf/core"
      xmlns:p="http://primefaces.org/ui">

    <ui:composition template="/templates/admin.xhtml">
        <ui:define name="title">
            <h:outputText value="Ksc Administrator - Event"></h:outputText>
        </ui:define>
        <ui:define name="currentPage">
            Event
        </ui:define>
        <ui:define name="mainContent">
            <h:form id="formData" styleClass="jsfcrud_list_form">
                <h:panelGroup id="messagePanel" layout="block">
                    <h:messages errorStyle="color: red" infoStyle="color: green" layout="table"/>
                </h:panelGroup>
                <h:panelGroup >
                    <p:dataTable id="tableData" 
                                 style="width: 100%"
                                 value="#{eventListController.listData}" 
                                 filteredValue="#{eventListController.filterList}"
                                 var="event"
                                 sortMode="multiple"
                                 paginatorTemplate="{CurrentPageReport}  {FirstPageLink} {PreviousPageLink} {PageLinks} {NextPageLink} {LastPageLink} {RowsPerPageDropdown}" 
                                 paginatorPosition="bottom" rows="15" paginator="true"
                                 rowsPerPageTemplate="15,25,40"
                                 resizableColumns="true"
                                 widgetVar="tableEvent"
                                 rowKey="#{event.id}"
                                 >
                        <p:column sortBy="id" 
                                  styleClass="colId"

                                  filterBy="id"
                                  filterMatchMode="contains">
                            <f:facet name="header">
                                <h:outputText value="Id"/>
                            </f:facet>
                            <h:outputText value="#{event.id}" title="#{event.id}"/>
                        </p:column>
                        <p:column sortBy="name"
                                  filterBy="name"
                                  filterMatchMode="contains"
                                  >
                            <f:facet name="header">
                                <h:outputText value="Name"/>
                            </f:facet>
                            <h:outputText value="#{event.name}" title="#{event.name}"/>
                        </p:column>
                        
                        <p:column
                            sortBy="activity"
                            filterBy="activity.name"
                            filterOptions="#{comboBoxModel.listActivity()}"
                            filterMatchMode="exact"
                            >
                            <f:facet name="header">
                                <h:outputText value="#{bundle.ListEventTitle_activity}"/>
                            </f:facet>
                            <h:outputText value="#{event.activity.name}"/>
                        </p:column>
                        <p:column
                            sortBy="conductTime"
                            >
                            <f:facet name="header">
                                <h:outputText value="Conduct Time"/>
                            </f:facet>
                            <h:outputText value="#{event.conductTime}">
                                <f:convertDateTime pattern="dd/MM/yyyy HH:mm:ss" />
                            </h:outputText>
                        </p:column>
                        <p:column
                            sortBy="fee"
                            filterBy="fee"
                            filterMatchMode="contains"
                            >
                            <f:facet name="header">
                                <h:outputText value="#{bundle.ListEventTitle_fee}"/>
                            </f:facet>
                            <h:outputText value="#{event.fee}"/>
                        </p:column>
                        <p:column
                            sortBy="address"
                            filterBy="address"
                            filterMatchMode="contains"
                            >
                            <f:facet name="header">
                                <h:outputText value="#{bundle.ListEventTitle_address}"/>
                            </f:facet>
                            <h:outputText value="#{event.address}"/>
                        </p:column>

                        <p:column styleClass="colAction">
                            <f:facet name="header">
                                <h:outputText value="&nbsp;"/>
                            </f:facet>
                            <h:outputText value="&nbsp;"/>
                            <h:link outcome="detail"  value="Update">
                                <f:param name="id" value="#{event.id}"/>
                            </h:link>
                            <p:spacer width="15px"/>
                            <p:commandLink 
                                oncomplete="dlgDelete.show();"
                                action="#{eventListController.prepareRemove()}" 
                                value="Remove">
                                <f:setPropertyActionListener target="#{eventListController.removeObject}" value="#{event}"/>
                            </p:commandLink>
                        </p:column>
                    </p:dataTable>
                </h:panelGroup>
            </h:form>
            <h:form id="formDelete">
                <p:confirmDialog widgetVar="dlgDelete" message="Do you want remove this event ?" id="dlgDelete">
                    <p:commandButton value="Yes" oncomplete="dlgDelete.hide()" 
                                     actionListener="#{eventListController.remove()}"
                                     update=":formData:tableData"
                                     >
                    </p:commandButton>
                    <p:commandButton value="No" oncomplete="dlgDelete.hide()"></p:commandButton>
                </p:confirmDialog>
            </h:form>
        </ui:define>
    </ui:composition>
</html>
